﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caifu.Datas;

namespace Caifu.Clients
{
    public class UserClient
    {
        public static readonly UserClient Instance = new UserClient();

        	/// <summary>
		/// 检测用户名的存在性;
		/// </summary>
		/// <returns>true:存在冲突，false:不存在冲突</returns>
        public Boolean CheckExistByName(String username)
		{
            return UserData.Instance.ConflictByName(username);
		}

		/// <summary>
		/// 检测邮箱的存在性;
		/// </summary>
		/// <returns>true:存在冲突，false:不存在冲突</returns>
        public Boolean CheckExistByEmail(String email)
		{
            return UserData.Instance.ConflictByEmail(email);
		}

		/// <summary>
		/// 添加用户
		/// </summary>
		public void AddUser(User user)
		{
             UserData.Instance.AddUser(user);
		}

		/// <summary>
		/// 修改密码
		/// </summary>
		/// <param name="email">用户邮箱</param>
		/// <param name="oldPwd">原密码</param>
		/// <param name="newPwd">新密码</param>
		public void ModifyPassword(String email, String oldPwd, String newPwd)
		{
            UserData.Instance.ModifyPassword(email, oldPwd, newPwd);
		}

		/// <summary>
		/// 根据邮箱返回用户
		/// </summary>
		/// <param name="email">邮箱</param>
		/// <returns>用户</returns>
		public User GetUserByEmail(String email)
		{
            return UserData.Instance.GetUserByEmail(email);
		}

		/// <summary>
		/// 修改用户昵称
		/// </summary>
		/// <param name="email">用户邮箱</param>
		/// <param name="username"></param>
		public void ModifyNickname(String email, String nickname)
		{
            UserData.Instance.ModifyNickname(email, nickname);
		}

		/// <summary>
		/// 根据ID获得用户信息；
		/// </summary>
		/// <param name="id">
		/// id 用户主键标示；
		/// </param>
		/// <returns></returns>
		public User GetUserById(Guid id)
		{
          return  UserData.Instance.GetUserById(id);
		}

		/// <summary>
		/// 用户登录
		/// </summary>
		/// <param name="mail">用户邮箱</param>
		/// <param name="password">密码</param>
		public User Login(String mail,String password)
		{
            return UserData.Instance.Login(mail, password);
		}
    }
}
